//
//  EFMentionDetailViewCell.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/16.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFMentionDetailViewCell.h"
#import "EFMentionDetailViewItem.h"

@interface EFMentionDetailViewCell()

@property(strong,nonatomic)UILabel* indexLabel;
@property(strong,nonatomic)UILabel* dateLabel;
@property(strong,nonatomic)UILabel* moneyLabel;
@property(strong,nonatomic)UILabel* statusLabel;
@property(strong,nonatomic)UIView* lineView;

@end


@implementation EFMentionDetailViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)setDistributorObject:(EFMyDistributorDetailItem *)item{
    [self.indexLabel setText:item.index];
    [self.dateLabel setText:item.time];
    [self.moneyLabel setText:item.commission];
    [self.moneyLabel setTextColor:kBlack999];
    self.statusLabel.hidden = YES;
}

-(void)setObject:(EFMentionDetailViewItem *)item{
    [self.indexLabel setText:item.index];
    [self.dateLabel setText:item.created_at];
    [self.moneyLabel setText:item.commission];
    if(item.status != 1 )
        self.statusLabel.hidden = NO;
    else{
        self.statusLabel.hidden = YES;
        if(item.status == 0){
            [self.statusLabel setText:@"*申请中"];
        }else if(item.status == 2){
            [self.statusLabel setText:@"*已拒绝"];
        }
    }

}


-(void)initView{
    [self.contentView addSubview:self.indexLabel];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.moneyLabel];
    [self.contentView addSubview:self.statusLabel];
    [self.contentView addSubview:self.lineView];
}


-(void)layoutSubviews{
    self.indexLabel.left = 20;
    self.indexLabel.top = 16;
    
    self.dateLabel.left = self.indexLabel.right + 7;
    self.dateLabel.top = 16;
    
    self.moneyLabel.left = kScreenWidth - self.moneyLabel.width - 20;
    self.moneyLabel.top = 15;
    
    self.statusLabel.left = kScreenWidth - self.statusLabel.width - 20;
    self.statusLabel.top = self.moneyLabel.bottom;
    
    self.lineView.left = 20;
    self.lineView.top = self.dateLabel.bottom + 13;
}



-(UILabel *)indexLabel{
    if(_indexLabel == NULL){
        _indexLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 16, 21)];
        _indexLabel.font = [UIFont systemFontOfSize:15];
        _indexLabel.textColor = kBlack999;
    }
    return _indexLabel;
}


-(UILabel *)dateLabel{
    if(_dateLabel == NULL){
        _dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 150, 21)];
        _dateLabel.font = [UIFont systemFontOfSize:15];
        _dateLabel.textColor = kBlack999;
    }
    return _dateLabel;
}


-(UILabel *)moneyLabel{
    if(_moneyLabel == NULL){
        _moneyLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 54, 21)];
        _moneyLabel.font = [UIFont systemFontOfSize:15];
        _moneyLabel.textColor = kBlack333;
    }
    return _moneyLabel;
}



-(UILabel *)statusLabel{
    if(_statusLabel == NULL){
        _statusLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 54, 14)];
        _statusLabel.font = [UIFont systemFontOfSize:10];
        _statusLabel.textColor = RGBCOLOR(0xD0021B);
        [_statusLabel setText:@"*申请中"];
    }
    return _statusLabel;
}

-(UIView *)lineView{
    if(_lineView == NULL){
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 1)];
        _lineView.backgroundColor = RGBCOLOR(0xECECEC);
    }
    return _lineView;
}



@end
